#pragma once

#include "raft/options.h"
#include "raft/raft.h"

namespace libraft {
class RaftNode {
 public:
  RaftNode(Options& options);

  ~RaftNode();

  void StopLoop();

  std::shared_ptr<Raft> StartNode(const std::string &path);
  std::shared_ptr<Raft> GetRaft() { return raft_; }

 private:
  void StartLoop(const std::string& path);
 private:
  RaftNode(const RaftNode&);
  void operator=(const RaftNode&);

  std::shared_ptr<Raft> raft_;
  mutable std::mutex mutex_;
  std::unique_ptr<std::thread> bg_thread_;
  std::condition_variable condition_;
  Options& options_;
};

}  // namespace libraft